﻿using System.ComponentModel.DataAnnotations;
using FluentValidationExample.Application.Products.Commands;
using FluentValidationExample.Application.Products.Contracts;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace FluentValidationExample.Controllers;

[ApiController]
[Route("api/[controller]/[action]")]
public class ProductsController : ControllerBase
{
    private readonly IMediator _mediator;

    public ProductsController(IMediator mediator)
    {
        _mediator = mediator;
    }

    [HttpPost]
    public IActionResult Create(CreateProductRequest productRequest)
    {
        _mediator.Send(new CreateCommand(Guid.NewGuid(), productRequest.ProductName));
        return Ok();
    }
}